//
//  SEGPictorialDetailModel.m
//  ExcellentHome
//
//  Created by 刘山 on 16/8/24.
//  Copyright © 2016年 陈区. All rights reserved.
//

#import "SEGPictorialDetailModel.h"

@implementation SEGPictorialDetailModel
+ (instancetype)initWithDictionary:(NSDictionary*)dictionary
{
    id obj = [[self alloc] init];
    [obj setValuesForKeysWithDictionary:dictionary];
    return obj;
}

- (void)setValue:(id)value forUndefinedKey:(NSString*)key
{
}

- (CGSize)sizeWithConstrainedWithString:(NSString*)str
{
    NSDictionary* attribute = @{ NSFontAttributeName : [UIFont systemFontOfSize:16] };

    CGSize textSize = [str boundingRectWithSize:CGSizeMake(LYScreenWidth() - 30, 0) options:NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attribute context:nil].size;
    return textSize;
}

- (void)setPictorialContent:(NSString*)pictorialContent
{
    _pictorialContent = [pictorialContent copy];
    CGFloat s1_H = [self sizeWithConstrainedWithString:[NSString stringWithFormat:@"话题介绍：%@", _pictorialContent]].height;
    CGFloat s2_H = [self sizeWithConstrainedWithString:@"话题介绍"].height;
    _canExplan = s1_H / s2_H > 4 ? YES : NO;
}

- (void)setIsShade:(NSString*)isShade
{
    _isShade = [[SEGUtils ValueToString:isShade] copy];
}

- (instancetype)init
{
    if (self == [super init]) {
        _pictorialTitle = @"";
        _labDesc = @"";
        _pictorialContent = @"";
        _img = @"";
        _isShade = @"";
    }
    return self;
}
@end
